package com.example.elasticsearch.repository;

import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

/**
 * @Description
 * @Author Mokairui
 * @Since 2021/11/6
 */
public class ItemRepository {
    @Autowired
    RestHighLevelClient highLevelClient;

    RestClient lowLevelClient = highLevelClient.getLowLevelClient();

    public void test() throws IOException {

//        IndexRequest request = new IndexRequest("spring-data")
//                .id(randomID())
//                .source(singletonMap("feature", "high-level-rest-client"))
//                .setRefreshPolicy(IMMEDIATE);
//
//        IndexResponse response = highLevelClient.index(request, RequestOptions.DEFAULT);
    }
}
